
#ifndef DB_H
#define DB_H

#include "../bzip2/bzlib.h"
#include "../sqlite/sqlite3.h"

#define TITLE_LEN 128

typedef struct {
    int id;
    int db;
    wchar_t title[TITLE_LEN];
} TITLE_LIST;

typedef struct FORM_HELPER {
    wchar_t* keyword;
    TITLE_LIST* list;
    int total;
    int offset;
    int search;
    int count;
    int select;
    int focus;
} FORM_HELPER;

#ifdef __cplusplus
extern "C"
{
#endif

int openTitleDatabase(void);
int openTextDatabase(int db);
int closeTitleDatabase(void);
int closeTextDatabase(void);
int searchTitle(FORM_HELPER* fh, int limit);
int searchID(wchar_t* key, TITLE_LIST* list);
void* searchText(int id, int db, int* err);
void* getText(int id, int db, int* err);
int searchCount(FORM_HELPER* fh);

#ifdef __cplusplus
}
#endif
#endif
